<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> -->
    <script src="../node_modules/vue/dist/vue.global.js"></script>
</head>

<body>
    <div id="app">
        <!-- 使用子组件 -->
        <part :tochilddata="tochilddata"></part>
        <p @click="count++">
            父中的count: {{count}}
        </p>
    </div>
</body>

</html>
<script>
    // 通过props 给子组件传递一个函数, 然后该函数的返回值为父组件中的数据,然后子组件接收该函数, 并且
    // 调用执行, 然后这样就在子组件 中获取了父组件中的数据


    const { createApp } = Vue;
    const vm = createApp({
        data() {
            return {
                count: 0
            }
        },
        methods: {
            tochilddata() {
                return this.count
            }
        },
        components: {
            part: {
                template: `<div>
                                <p>我是子组件--{{tochilddata()}}</p>
                           </div>`,
                props: ['tochilddata']
            }
        }


    });

    //挂载根实例到根节点
    vm.mount('#app')

</script>